<%@ page import="com.informet.ipd.modelo.dao.FinaMetaDao" %>
<%@ page import="com.informet.ipd.modelo.vo.FinaMetaMVO" %>
<%@ page import="com.informet.ipd.struts.form.PEIForm" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.swing.JOptionPane"%>
<%@ page language="java"  pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="/tags/c" prefix="c"%>

<%

            StringBuffer cadenaSalida = new StringBuffer();
            List lista = null;

            Double mes1 = Double.parseDouble(request.getParameter("mes1"));
            Double mes2 = Double.parseDouble(request.getParameter("mes2"));
            Double mes3 = Double.parseDouble(request.getParameter("mes3"));
            Double mes4 = Double.parseDouble(request.getParameter("mes4"));
            Double mes5 = Double.parseDouble(request.getParameter("mes5"));
            Double mes6 = Double.parseDouble(request.getParameter("mes6"));
            Double mes7 = Double.parseDouble(request.getParameter("mes7"));
            Double mes8 = Double.parseDouble(request.getParameter("mes8"));
            Double mes9 = Double.parseDouble(request.getParameter("mes9"));
            Double mes10 = Double.parseDouble(request.getParameter("mes10"));
            Double mes11 = Double.parseDouble(request.getParameter("mes11"));
            Double mes12 = Double.parseDouble(request.getParameter("mes12"));
             double ppto = Double.parseDouble(request.getParameter("ppto"));
           
            FinaMetaDao supportFacade = new FinaMetaDao();
            PEIForm form1 = new PEIForm();
            FinaMetaMVO oFMe = null;
            try {
                int codAP = Integer.parseInt(request.getParameter("codAP"));
                int codFM = Integer.parseInt(request.getParameter("codFM"));
                int tipo = Integer.parseInt(request.getParameter("tipo"));
                oFMe = new FinaMetaMVO(codFM,codAP,mes1,mes2,mes3,mes4,mes5,mes6,mes7,mes8,mes9,mes10,mes11,mes12);
                double total=mes1+mes2+mes3+mes4+mes5+mes6+mes7+mes8+mes9+mes10+mes11+mes12;
                if(total==ppto){
                        supportFacade.spManM(tipo, oFMe);
}
                    else{
                    JOptionPane.showMessageDialog(null, "Ingresar todo el presupuesto asignado");
                    }

                
                lista = supportFacade.getFiltroM(codAP);
                form1.setListaFisiMeta(lista);
                cadenaSalida.append("<table id='tabla1' width='99%' align='right' class='userTable'>");
                cadenaSalida.append("<tr class='even' align='center'>");
                cadenaSalida.append("<th class='textoTR'>#</th>");
                cadenaSalida.append("<th class='textoTR'>PPTO Anual</th> ");
                cadenaSalida.append("<th class='textoTR'>PPTO I Semestre</th> ");
                cadenaSalida.append("<th class='textoTR'>PPTO II Semestre</th> ");
                             cadenaSalida.append("<th class='textoTR'>Editar</th>");
                cadenaSalida.append("<th class='textoTR'>Eliminar</th> ");
                cadenaSalida.append("</tr>");
                 int i=1;
                Iterator it = lista.iterator();
                while (it.hasNext()) {
                    oFMe = (FinaMetaMVO) it.next();
                    cadenaSalida.append("<tr align='center'> ");
                    cadenaSalida.append("<td width='10%' align='center'>" +i++ + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe.getPPto_Anual() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe.getSemestreI() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>" + oFMe.getSemestreII() + "</td>");
                    cadenaSalida.append("<td width='10%' align='center'>");
                    cadenaSalida.append("<img style='cursor:pointer' title='Editar' alt='Editar' border=0  src='images/b_edit.png' onclick=\"editarT('"+oFMe.getNUM_CODACTPER_PK()+"','"+oFMe.getNUM_MES1FINAMETAM()+"','"+oFMe.getNUM_MES2FINAMETAM()+"','"+oFMe.getNUM_MES3FINAMETAM()+"','"+oFMe.getNUM_MES4FINAMETAM()+"','"+oFMe.getNUM_MES5FINAMETAM()+"','"+oFMe.getNUM_MES6FINAMETAM()+"','"+oFMe.getNUM_MES7FINAMETAM()+"','"+oFMe.getNUM_MES8FINAMETAM()+"','"+oFMe.getNUM_MES9FINAMETAM()+"','"+oFMe.getNUM_MES10FINAMETAM()+"','"+oFMe.getNUM_MES11FINAMETAM()+"','"+oFMe.getNUM_MES12FINAMETAM()+"','"+oFMe.getNUM_CODFINAMETAM_PK()+"');\">");
                    cadenaSalida.append("</td>");
                   
                    cadenaSalida.append("<td width='10%' align='center'> ");
                    cadenaSalida.append("<img style='cursor:pointer' title='Eliminar' alt='Eliminar' border=0  src='images/b_drop.png' onclick=\"eliminar('"+oFMe.getNUM_CODFINAMETAM_PK()+"','"+oFMe.getNUM_CODACTPER_PK()+"');\" >");
                    
                    cadenaSalida.append("</td>");
                    cadenaSalida.append("</tr>");
                }
            } catch (Exception e) {
                cadenaSalida.append(e.toString());
                   
            }
            out.print(cadenaSalida);
%>